package org.september.pisces.excel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.september.pisces.excel.controller.ExcelTmplController;
import org.september.pisces.module.api.PiscesModule;
import org.september.pisces.module.api.WebMenu;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;


/**
 * 标注service，用于主工程发现插件模块
 * excel处理，通过模板方式实现导出excel。
 * @author yexinzhou
 *
 */
@Configuration
@ComponentScan(basePackageClasses = ExcelTmplModule.class)
public class ExcelTmplModule implements PiscesModule {

	public static final String Excel模板="Excel模板";

	private static Map<String,List<WebMenu>> moduleMap = new HashMap<>();
	static {
		List<WebMenu> menus1 = new ArrayList<>();
		menus1.add(new WebMenu("Excel导出-Excel模板", ExcelTmplController.List_Page, "layui-icon-component")
				.addPermission("列表页面", PiscesExcelPermission.模板列表.getUrls())
				.addPermission("导入模板", PiscesExcelPermission.导入模板.getUrls())
				.addPermission("删除模板", PiscesExcelPermission.删除模板.getUrls()));
		moduleMap.put(Excel模板, menus1);
	}
	public static List<WebMenu> getWebMenus(String moduleName) {
		return moduleMap.get(moduleName);
    }

	public ExcelTmplModule(){
		System.out.println(ExcelTmplModule.class.getName()+ " init..");
	}

	public String[] getMyBatisMapperLocation() {
		return new String[] {"classpath:"+ExcelTmplModule.class.getPackageName().replace(".", "/")+"/mapper/*.xml"};
	}

	public String[] getEntityPackages() {
		return new String[] {ExcelTmplModule.class.getPackageName()+".entity"};
    }

}
